import type { Logistics } from '@/types/order'
import type { AddressItem, OrderDetail, OrderPre } from '@/types/order'
import { request } from '@/utils/request'

// 获取处方的详细信息
export const getMedicalOrderPre = (data: { prescriptionId: string }) =>
  request<OrderPre>('patient/medicine/order/pre', 'get', data)
// 获取地址
export const getAddressList = () =>
  request<AddressItem[]>('patient/order/address', 'get')

// 创建药品订单
export const createMedicalOrder = (data: {
  id: string
  couponId?: string
  addressId: string
}) => request<{ id: string }>('patient/medicine/order', 'post', data)

// 药品订单-查询订单详情信息
export const getMedicalOrderDetail = (id: string) =>
  request<OrderDetail>(`patient/medicine/order/detail/${id}`)

// 物流接口
export const getMedicalOrderLogistics = (id: string) =>
  request<Logistics>(`patient/order/${id}/logistics`, 'get')
